package cn.hdu.liang.pipe;

import java.io.IOException;
import java.io.PipedInputStream;

public class ReadData {
    public void readMethod(PipedInputStream input) {
        try {
            System.out.println("read: ");
            byte[] bytes = new byte[20];
            int readLen = input.read(bytes);
            while(readLen != -1) {
                String newData = new String(bytes, 0, readLen);
                System.out.print(newData);
                readLen = input.read(bytes);
            }
            System.out.println();
            input.close();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}
